<%- include ../common/header %>
<link rel="stylesheet" type="text/css" href="/css/common/dialog.css"/>
<link rel="stylesheet" type="text/css" href="/css/doExam/index.css"/>
<script type="text/javascript" src="/js/libs/iscroll.js"></script>
<script>
	var myscroll,pullUpEl, pullUpOffset;
	function loaded(){
		pullUpEl = document.getElementById('pullUp');	
		pullUpOffset = pullUpEl.offsetHeight;
		
		myscroll = new iScroll("wrapper",{
			scrollY:true,
			freeScroll:true,
			hScrollbar:false,
            vScrollbar:false,
            lockDirection:true,
            hScroll :false, 
            useTransition: false,
            onRefresh: function () {
				if(pullUpEl.className.match('loading')) {
					pullUpEl.className = '';
					pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
				}
			},
            onScrollMove:function(){
            	if(this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
					pullUpEl.className = 'flip';
					pullUpEl.querySelector('.pullUpLabel').innerHTML = '松手开始加载...';
					this.maxScrollY = this.maxScrollY;
				} else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
					pullUpEl.className = '';
					pullUpEl.querySelector('.pullUpLabel').innerHTML = '上拉加载更多...';
					this.maxScrollY = pullUpOffset;
				}
            },
            onScrollEnd: function () {
            	myscroll.refresh();
				if(pullUpEl.className.match('flip')) {
					pullUpEl.className = 'loading';
					pullUpEl.querySelector('.pullUpLabel').innerHTML = '加载中...';				
					pullUpAction();	// Execute custom function (ajax call?)
				}
			}
		});
	}
	window.addEventListener("DOMContentLoaded", loaded, false);
</script>
<div class="common_header">
	<div class="back"><img src="/images/back.png"/></div>
	<span class="title"></span>
</div>
<div id="loadingDiv" class="loader"></div>
<!-- 搜索试题 -->
<div class="search_exam" id="wrapper">
	<div id="scroller">
		<ul class="exam_ullist">
		</ul>
		<!--  上拉加载  -->
		<div id="pullUp" style="display:none;">
			<span class="pullUpIcon"></span><span class="pullUpLabel">上拉加载更多...</span>
		</div>
	</div>
</div>

<!-- 没有搜索结果 -->
<div class="noSearch">
	<img src="/images/nosearch.png" />
	<p>未找到该试题</p>
</div>
<%- include ../common/footer %>
<script data-main="/js/doExam/searchExam.js" src="/js/libs/require.js"></script>